package com.administrator.cloudapplication.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.administrator.cloudapplication.fragments.InfomationFragment;
import com.administrator.cloudapplication.fragments.MediaFragment;
import com.administrator.cloudapplication.fragments.MoreFragment;
import com.administrator.cloudapplication.fragments.NearFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/11.
 */

public class MyFragmentPagerAdapter extends FragmentPagerAdapter{
    InfomationFragment mInfomationFragment;
    MediaFragment mMediaFragment;
    MoreFragment mMoreFragment;
    NearFragment mNearFragment;
    List<Fragment> mFagmentList;
    public void  initView(){
        mFagmentList=new ArrayList<>();
        mInfomationFragment = new InfomationFragment();
        mMediaFragment = new MediaFragment();
        mNearFragment = new NearFragment();
        mMoreFragment = new MoreFragment();
        mFagmentList.add(mInfomationFragment);
        mFagmentList.add(mMediaFragment);
        mFagmentList.add(mNearFragment);
        mFagmentList.add(mMoreFragment);
    }
    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        initView();
        return mFagmentList.get(position);
    }

    @Override
    public int getCount() {
        initView();
        return mFagmentList.size();
    }
}
